<?php

    echo '<?xml version="1.0" encoding="utf-8" ?>';

?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title><?php echo $desc; ?></title>
    <link><?php echo $url; ?></link>
    <description><?php echo $desc; ?></description>
    <language><?php echo $lang; ?></language>
    <pubDate><?php echo date("D, j M Y H:i:s", gmmktime()) . ' GMT';?></pubDate>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <generator><?php echo $generator; ?></generator>
    <managingEditor><?php echo $email; ?></managingEditor>
    <webMaster><?php echo $email; ?></webMaster>

<?php

foreach ($quotes as $quote)
{
		$tags = trim($quote['Quote']['tags']);
		
		if($tags == '')
		{
			$tags = array();
		}
		else
		{
			$tags = explode(' ', trim($quote['Quote']['tags']));
			sort($tags);
		}
		
?>
    <item>
      <title>#<?php echo $quote['Quote']['id'] . ' (' . trim($quote['Quote']['tags']) . ')'; ?></title>
      <link><?php echo $url . 'quotes/view/' . $quote['Quote']['id']; ?></link>
      <description><![CDATA[
        <?php echo $quote['Quote']['body']; ?>
        <br /><br /><small>NOTES:
        <?php echo $quote['Quote']['notes']; ?></small>
        <br /><br /><small>TAGS:
        <?php
                foreach($tags as $tag)
                {
                    echo '<a href="' . $url . 'quotes/tag/' . $tag . '">' . $tag . '</a> ';
                }
   		?></small>
      ]]></description>
      <pubDate><?php echo gmdate("D, j M Y H:i:s", $quote['Quote']['created']) . ' GMT'; ?></pubDate>
      <guid><?php echo $url . 'quotes/view/' . $quote['Quote']['id']; ?></guid>
    </item>

<?php

}

?>

  </channel>
</rss> 